package model;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;

import db.DBUtil;
import db.DbException;

public class DisciplineModel {
	private static String selectStr = "SELECT name FROM Disciplines LIMIT 4";

	public static Vector<String> getAllDisciplines() throws DbException {
		try {
			// Create the statement
			Statement stmt = DBUtil.createStatement();

			ResultSet rs = stmt.executeQuery(selectStr);

			Vector<String> discs = new Vector<String>();
			while (rs.next()) {
				discs.add(rs.getString(2));
			}

			rs.close();
			stmt.close();
			DBUtil.close();

			return discs;
		} catch (SQLException ex) {
			throw new DbException(ex);
		}
	}
}
